﻿using System.Text.RegularExpressions;

namespace NoteHelper.Utils
{
    public static class StringHelper
    {
        /// <summary>  
        /// 移除前后空格，并且把中间多个连续空格合并成一个空格  
        /// </summary>  
        /// <param name="source">待处理的字符串</param>  
        /// <returns>合并空格后的字符串</returns>  
        public static string MergeSpace(string source)
        {
            if (!string.IsNullOrEmpty(source) && source.Length > 0)
            {
                source = source.Trim();
                source = new Regex("[\\s]+").Replace(source, " ");
            }
            return source;
        }
    }
}
